package acwing;

import java.io.*;
import java.util.*;

public class ac3382 {
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
    static final int N = 1000010;
    static int n;
    static int[] dp = new int[N];

    static int cin() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws IOException {
        n = cin();
        dp[0] = 1;
        for (int i = 1; i <= n; i *= 2 ) {
            for (int j = i; j <= n; j ++ ) {
                dp[j] = (dp[j] + dp[j - i]) % (int) 1e9;
            }
        }
        out.println(dp[n]);
        out.close();
    }
}